/* 
 * originally if-linux.c from dhcpcd - DHCP client daemon
 *
 * Original code Copyright 2006-2008 Roy Marples <roy@marples.name>
 * All rights reserved
 *
 * parts Copyright 2011 Daniel Drown <dan-android@drown.org>
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * netlink.h - kernel api for network interface configuration
 */
#ifndef __NETLINK_H__
#define __NETLINK_H__ 1

#include <linux/netlink.h>

#define LINK_UP 1
#define LINK_DOWN 0
int if_link(const char *ifname, int mtu, int set_up);

#define ADDRESS_ADD 1
#define ADDRESS_DELETE 0
int if_address(const char *ifname, int family, const void *address, int cidr, const void *broadcast, int add_addr);

#define ROUTE_DELETE 0
#define ROUTE_REPLACE 1
#define ROUTE_CREATE 2
int if_route(const char *ifname, int family, const void *destination, int cidr, const void *gateway, int metric, int mtu, int change_type);

typedef int netlink_callback(struct nlmsghdr *, void *);
int send_netlink_cb(struct nlmsghdr *hdr, netlink_callback *callback, void *callback_data);

#endif // __NETLINK_H__
